﻿(function () {
	var url = location.href;
	// replace www.test.com with your domain
	//if ( (url.indexOf('iqiju.com') != -1) && navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i) )
	//if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)) {
	//location.href = 'http://mobile.iqiju.com/mobile';
	//	location.href = 'http://mobile.iqiju.com/';
	//}
	if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)) {
		console.log('mobile 1');
		if(url.indexOf('Root-m')<0){
			location.href = 'Root-m/?v='+Math.random();
		}

	}else{
		console.log('PC');
	}

})();

$(function(){
	//全屏滚动
	$('#dowebok').fullpage({
		anchors: ['page1', 'page2', 'page3', 'page4'],
		menu: '#menu',
		'navigation': true,  //导航
		navigationColor:"#ffffff",
		loopBottom: false,
		scrollingSpeed:700,
		css3:true,
	});
	//menu
	var ulWidth=$(".menu").width();
	window.onresize=function(){
		ulWidth=(".menu").width();
		var liWidth=ulWidth*0.25;
		$(".option").width(liWidth);

		var liWidth=ulWidth*0.25;
	}
	console.log($("body").height())
	$(".bgbox video").height($("body").height());
	//第二屏
	var width=$(".screen").width();
	window.onresize=function(){
		width=$(".screen").width();
	}
	var number=0;
	function change (){
		$(".nav a").css({"font-size":"28px","border-bottom":"0px"});
		if(number>3){
			number=0;
		}
		if(number==0){
			$(".nav1").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		};
		if(number==1){
			$(".nav2").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		}
		if(number==2){
			$(".nav3").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		}
		if(number==3){
			$(".nav4").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		}
		$(".figure").css("margin-left",-number * width + "px");
		number++;
	}
	var timers=setInterval(change, 4000);
	$(".nav1").hover(function(){
		clearInterval(timers);
		number=0;
		$(".nav a").css({"font-size":"28px","border-bottom":"0px","color":" rgba(255, 255, 255, 0.6)"});
		$(".nav1").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		$(".figure").css("margin-left",-number * width + "px");
	},function(){
		timers=setInterval(change, 4000);
	});
	$(".nav2").hover(function(){
		clearInterval(timers);
		$(".nav a").css({"font-size":"28px","border-bottom":"0px","color":" rgba(255, 255, 255, 0.6)"});
		$(".nav2").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		number=1;
		$(".figure").css("margin-left",-number * width + "px");
	},function(){
		timers=setInterval(change, 4000);
	});
	$(".nav3").hover(function(){
		clearInterval(timers);
		$(".nav a").css({"font-size":"28px","border-bottom":"0px","color":" rgba(255, 255, 255, 0.6)"});
		$(".nav3").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		number=2;
		$(".figure").css("margin-left",-number * width + "px");
	},function(){
		timers=setInterval(change, 4000);
	});
	$(".nav4").hover(function(){
		clearInterval(timers);
		$(".nav a").css({"font-size":"28px","border-bottom":"0px","color":" rgba(255, 255, 255, 0.6)"});
		$(".nav4").css({"font-size":"30px","border-bottom":"2px solid #f62489","color":"#ffffff"});
		number=3;
		$(".figure").css("margin-left",-number * width + "px");
	},function(){
		timers=setInterval(change, 4000);
	});

	$(".navigation").on("click",function(){
		$('.menu').css("display","block")
	})
	$(".close").on("click",function(){
		$('.menu').css("display","none");
	})
	$(".option").on("click",function(){
		$('.menu').css("display","none");
	})
//品牌联合部分
	function brand(){
		$(".cooperation").css("display","block");
		$(".text-one").css("display","block");
		$(".text-two").css("display","none");
		$(".text-three").css("display","none");
		$(".p1").css("display","block");
		$(".p2").css("display","none");
		$(".p3").css("display","none");
		$(".nav-one").css("border-bottom","2px solid #e4006e")
		$(".nav-two").css("border-bottom","0px")
		$(".nav-three").css("border-bottom","0px")
	}
//活动合作
	function activity (){
		$(".cooperation").css("display","block");
		$(".text-one").css("display","none");
		$(".text-two").css("display","block");
		$(".text-three").css("display","none");
		$(".p1").css("display","none");
		$(".p2").css("display","block");
		$(".p3").css("display","none");
		$(".nav-one").css("border-bottom","0px")
		$(".nav-two").css("border-bottom","2px solid #e4006e")
		$(".nav-three").css("border-bottom","0px")
	}
//公益合作
	function welfare (){
		$(".cooperation").css("display","block");
		$(".text-one").css("display","none");
		$(".text-two").css("display","none");
		$(".text-three").css("display","block");
		$(".p1").css("display","none");
		$(".p2").css("display","none");
		$(".p3").css("display","block");
		$(".nav-one").css("border-bottom","0px")
		$(".nav-three").css("border-bottom","2px solid #e4006e")
		$(".nav-two").css("border-bottom","0px")
	}
	//第四屏二级页面的跳转
	$(".brand").on("click",brand);
	$(".activity").on("click",activity);
	$(".welfare").on("click",welfare);
	//导航跳转
	$(".nav-one").on("click",brand);
	$(".nav-two").on("click",activity);
	$(".nav-three").on("click",welfare);
	//二级页面的关闭
	$(".cooperation-close").on("click",function(){
		$(".cooperation").css("display","none");
	})
	$("#businessEnter li").hover(function (){
		$("#businessEnter li .zhezhao").show();
		$(this).find(".zhezhao").hide();
	},function (){
		$("#businessEnter li .zhezhao").hide();
	})
	// setTimeout(function () {
	// 	document.getElementsByClassName("bgvideo")[0].play();
	// },1)
	// var hrefArry = ['http://www.qxiu.com','http://www.ggcj.com','http://www.guagua.cn/','https://www.guagualive.com']
	// $("#businessEnter li").click(function (){
	// 	var index = $(this).index();
	// 	window.open(hrefArry[index]);
	// });
});
